﻿<%@ Page Title="Reports Manager" Language="C#" MasterPageFile="~/Backoffice/BackOffice.Master"
    AutoEventWireup="true" CodeBehind="ReportsManager.aspx.cs" Inherits="TreaShares.Backoffice.Administrator.ReportsManager" %>
<%@ MasterType VirtualPath="~/Backoffice/BackOffice.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="Id" DataSourceID="ObjectDataSource1" 
    onrowcreated="GridView1_RowCreated">
        <Columns>
            <asp:BoundField DataField="DisplayName" HeaderText="Display Name" />
            <asp:BoundField DataField="ReportClassName" HeaderText="Report Class Name"/>
            <asp:BoundField DataField="Description" HeaderText="Description"/>
            <asp:CheckBoxField DataField="IsPublic" HeaderText="Is Public" />
            <asp:HyperLinkField DataNavigateUrlFields="Id , DisplayName" DataNavigateUrlFormatString="Report2Clients.aspx?ReportId={0}&DisplayName={1}"
                HeaderText="Associate Clients" DataTextField="Cnt" />
            <asp:CommandField ShowEditButton="True" />
            <asp:TemplateField HeaderText="Delete" HeaderStyle-HorizontalAlign="Center">
                <ItemStyle HorizontalAlign="Center" />
                <ItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/Icons/trash.gif"
                        CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete')" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            No Reports found
        </EmptyDataTemplate>
    </asp:GridView>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
        SelectMethod="Select" 
        TypeName="TreaShares.Backoffice.Controlers.ReportsManager" 
        DeleteMethod="Delete"
        UpdateMethod="Update">
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="id" Type="Int32" />
            <asp:Parameter Name="displayName" Type="String" />
            <asp:Parameter Name="reportClassName" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="isPublic" Type="Boolean" />
        </UpdateParameters>
    </asp:ObjectDataSource>
    <br /><br />
    <table border="0" style="width: 50%" cellpadding="2" cellspacing="2">
        <tr>
            <td colspan="2" class="HeaderStyle">
                Insert new report
            </td>
        </tr>
        <tr>
            <td>
                Report Name(Class name as shown in visual studio):
            </td>
            <td>
                <asp:TextBox ID="txtReportName" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txtReportName" ErrorMessage="Required Field" 
                    ValidationGroup="G2"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Display Name:
            </td>
            <td>
                <asp:TextBox ID="txtDisplayName" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ControlToValidate="txtDisplayName" ErrorMessage="Required Field" 
                    ValidationGroup="G2"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td valign="top">
                Description:
            </td>
            <td>
                <asp:TextBox ID="txtDescription" runat="server" Rows="5" TextMode="MultiLine"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                Is public:
            </td>
            <td>
                <asp:CheckBox ID="cbIsPublic" runat="server" Checked="true"></asp:CheckBox>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="right">
                <input type="reset" name="" id="btnReset" value="Reset" class="button" />
                <asp:Button Text="Insert" name="btnReportInsert" ID="btnReportInsert" runat="server"
                    class="button" ClientIDMode="Static" onclick="btnReportInsert_Click" 
                    ValidationGroup="G2"  />
            </td>
        </tr>
    </table>
</asp:Content>
